#include <stdio.h>
#include <string.h>
#include "../include/utils.h"

#define MAX_LEN 128 
int main()
{	
	//test Hex2Char
	char toc;
	Hex2Char(12, &toc);
	printf("toc=%c\n", toc);

	//test Char2Hex
	int toi;
	Char2Hex('A', &toi);
	printf("toi = %d \n", toi);

	unsigned char ba[MAX_LEN];
	unsigned char bs[MAX_LEN * 8] = "00100000000110010001001100010010";
	int len = 0;
	//test Bit2Byte
	Bitstr2ByteArr(bs, ba, &len);
	printf("ba={0x%x", ba[0]);
	for(int i = 1; i < len; i++)
		printf(",0x%x", ba[i]);
	printf("};len=%d\n", len);

	//test Byte2Bit
	unsigned char ba2[MAX_LEN] = "\x20\x19\x13\x12";
	unsigned char bs2[MAX_LEN * 8] = "";
	int len2 = 0;
	ByteArr2Bitstr(ba2, bs2, &len2);
	for(int i = 0; i < len2*8; i++){
		printf("%c", bs2[i]);
	}
	printf("\n");

	//test int2Byte
	unsigned char ba3[4];
	unsigned int num = 123456789;
	Int2ByteArr(num, ba3);
	printf("ba3={0x%x", ba3[0]);
	for(int i = 1; i < 4; i++)
		printf(",0x%x", ba3[i]);
	printf("};\n");

	//test Byte2Int
	unsigned char ba4[4] = "\x07\x5B\xCD\x15";
	unsigned int num2;
	ByteArr2Int(ba4, &num2);
	printf("num2 = %u\n", num2);
	return 0;
}
